package com.lyf.convert_x.utils;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: com.lyf.convert_x.utils
 * @description:
 * @author: GG-lyf
 * @create: 2024/10/28
 */
public class StringUtils {
    public static List<String> splitCamelCase(String input) {
        List<String> words = new ArrayList<>();
        StringBuilder currentWord = new StringBuilder();

        for (int i = 0; i < input.length(); i++) {
            char c = input.charAt(i);

            if (Character.isUpperCase(c)) {
                if (currentWord.length() > 0 && i > 0 && !Character.isUpperCase(input.charAt(i - 1))) {
                    words.add(currentWord.toString());
                    currentWord.setLength(0);
                }
                currentWord.append(c);
            } else {
                currentWord.append(c);
            }
        }

        if (currentWord.length() > 0) {
            words.add(currentWord.toString());
        }

        return words;
    }
}
